package com.order_system.controller;


import com.order_system.dto.OrderListDto;
import com.order_system.entity.ResModel;
import com.order_system.service.OrderListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李阳
 * @since 2023-01-06
 */
@RestController
@RequestMapping("/api/order")
public class OrderListController {

    @Autowired
    private OrderListService orderListService;

    /**
     * 查询顾客历史订单
     * @param customerId 顾客id
     * @return
     */
    @GetMapping("/list/{customerId}")
    public ResModel list(@PathVariable Integer customerId){
        return orderListService.getList(customerId);
    }

    /**
     * 查询销售历史订单
     * @return
     */
    @GetMapping("/list")
    public ResModel list(){
        return orderListService.getOrderList();
    }

    /**
     * 创建订单
     * @param orderListDto 订单实体
     * @return
     */
    @PostMapping(value = "/save",produces = "application/json")
    public ResModel add(@RequestBody OrderListDto orderListDto){
        return orderListService.add(orderListDto);
    }

}

